import Vue from 'vue'  //导入vue
import Vuex from 'vuex' //导入vuex
//vue挂载vuex
Vue.use(Vuex)
//导入插件vuex-persistedstate保持数据不被刷新掉
// import createPersistedState from 'vuex-persistedstate'

//创建vuex实例
    const store =new Vuex.Store({
        state:sessionStorage.getItem('state') ? JSON.parse(sessionStorage.getItem('state')): {
            //v-if的flag
            flag:false,
            token:'',
            userid:''
        },
        mutations:{
            //改变flag响应式方法
            changeFlag(state){
                state.flag = true;
            },
            addToken(state,data){
                state.token = data;
            },
            addUserId(state,data){
                state.userid = data;
            }
        },
        // plugins:[createPersistedState()],
    })


    export default store //导入store
